package cn.kent;

import java.util.Comparator;

/**
 * lambda 表达式初探
 */
public class LambdaTest01 {
    public static void main(String[] args) {
        final Runnable r1 = new Runnable() {
            public void run() {
                System.out.println("Hello,World!");
            }
        };
        r1.run();

        Runnable r2 = () -> System.out.println("Hello,World2!");
        r2.run();

        System.out.println("===============================");

        final Comparator<Integer> com1 = new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return Integer.compare(o1, o2);
            }
        };
        System.out.println(com1.compare(12, 21));

        // Lambda 表达式
        Comparator<Integer> com2 = (o1, o2) -> Integer.compare(o1, o2);
        // 方法引用
        Comparator<Integer> com3 = Integer::compare;
    }
}
